by Mark van Renswoude (6 Submissions)
Category: DirectX
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(20 Votes)

After figuring out how to rotate 2D sprites using Direct3D (check my other submissions), I wanted to do lighting. After reading some tutorials I gave up, they all used 3D, while I wanted to do 2D. There are other ways of faking light; making tiles in multiple shades at either design time or run time, but they're limited...
So here it is: faked light using Direct3D to simulate 2D! It looks great, runs fast (if you've got a 3D card, my P133 with Voodoo 3 could easily run it, although not on software rendering mode), and allows dynamic setting of light brightness and color.
So how does it work? Easy: it sets the color of a vertex (corner) to the brightness of the light at that specific place, after which Direct3D automatically adjusts the texture!
Some limitations though: